<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>CruiseControl.NET : Git Source Control Block</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            CruiseControl.NET : Git Source Control Block
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jul 03, 2009 by <font color="#0050B2">dna</font>.
				    </div>

				    <div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>The Git Source Control Block  will be available in the 1.5 release.</b><br />
<p>JIRA Issue for progress tracking: <a href="http://jira.public.thoughtworks.org/browse/CCNET-1554">http://jira.public.thoughtworks.org/browse/CCNET-1554</a></p></td></tr></table></div>
<p>CruiseControl.NET from version 1.5 on provide support for the Git Distributed Version Control System.</p>

<p>Homepage: <a href="http://www.git-scm.com">http://www.git-scm.com</a></p>

<h3><a name="GitSourceControlBlock-Howdoesthiswork%3F"></a>How does this work?</h3>


<h4><a name="GitSourceControlBlock-Localrepositoryinitialization"></a>Local repository initialization</h4>

<p>The Git Source Control Block will check whenever the specified working directory exist or not. If it does not exist a "git clone" command is issued to create and setup the local repository. Also the configuration settings "user.name" and "user.email" for the local repository will be set with "git config" if both are provided.</p>

<p>If the working directory exists but is not a git repository (e.g. the .git directory is missing) it will be deleted and the "git clone" and configuration instructions described above will be issued.</p>

<p>If the working directory is already the root of an existing git repository no initialization is done.</p>

<h4><a name="GitSourceControlBlock-Checkingformodifications"></a>Checking for modifications</h4>

<p>One the repository is initialized the "git fetch origin" command is issued to fetch the remote changes. In the next step the sha-1 hash of the specified remote branch and the local checkout is compared. If they're identical Cruise Control.NET will expect that there are no changes.</p>

<p>If the 2 sha-1 hashes are different a "git log &#45;-name-status &#45;-before=... &#45;-after=..." command is issued to get a list of the new commits and their changes.</p>

<h4><a name="GitSourceControlBlock-Gettingthesource"></a>Getting the source</h4>

<p>Once Cruise Control.NET has modifications detected and the 'autoGetSource' property is set to 'true' the "git checkout &#45;f origin/$NameOfTheBranch" command is issued. Also the "git clean &#45;f &#45;d &#45;x" command to get a clean working copy to start a new build.</p>

<h4><a name="GitSourceControlBlock-Taggingasuccessfulbuild"></a>Tagging a successful build</h4>

<p>After a successful build and when the 'tagOnSuccess' property is set to 'true' the "git &#45;a &#45;m 'tagCommitMessage' tag 'build label'" command is issued and a "git push origin tag 'name of the tag'" to push the tag to the remote repository.</p>

<p>If 'commitBuildModifications' is set to 'true' then all modified files will be committed before tagging with a "git commit --all --allow-empty -m 'tagCommitMessage'". If you also set 'commitUntrackedFiles' to 'true' all untracked files that are not ignored by .gitignores will be added to the git index before committing and tagging with a "git add --all" command.</p>

<h3><a name="GitSourceControlBlock-UsingGitonWindows"></a>Using Git on Windows</h3>

<p>Download and install the latest version of msysgit.</p>
<ul>
	<li>Point the "executable" property to the git.cmd file (e.g. C:\Program Files\Git\cmd\git.cmd)</li>
	<li>or set the "path" environment variable to the "bin" directory of your msysgit instalation (e.g. C:\Program Files\Git\bin), the "HOME" environment variable to "%USERPROFILE%" and the "PLINK_PROTOCOL" environment variable to "ssh".</li>
</ul>


<p>Homepage: <a href="http://code.google.com/p/msysgit/">http://code.google.com/p/msysgit/</a></p>

<h3><a name="GitSourceControlBlock-UsingGitonUnix%28CruiseControl.NETwithMono%29"></a>Using Git on Unix (CruiseControl.NET with Mono)</h3>

<p>Make sure that you've the latest Git installed via your distributions packet manager and that git and all its required applications are in $PATH.</p>

<h3><a name="GitSourceControlBlock-AdditionalInformation"></a>Additional Information</h3>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>
<p>The default port git uses is 9418. Git over SSH uses port 22 by default. Make sure that your firewall is set up to handle this.</p></td></tr></table></div>

<h3><a name="GitSourceControlBlock-Examples"></a>Examples</h3>

<p>Minimalist Example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;sourcecontrol type=<span class="code-quote">"git"</span>&gt;</span>
    <span class="code-tag">&lt;repository&gt;</span>git://github.com/rails/rails.git<span class="code-tag">&lt;/repository&gt;</span>
<span class="code-tag">&lt;/sourcecontrol&gt;</span></pre>
</div></div>
<p>Full example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;sourcecontrol type=<span class="code-quote">"git"</span>&gt;</span>
    <span class="code-tag">&lt;repository&gt;</span>git://github.com/rails/rails.git<span class="code-tag">&lt;/repository&gt;</span>
    <span class="code-tag">&lt;branch&gt;</span>master<span class="code-tag">&lt;/branch&gt;</span>
    <span class="code-tag">&lt;autoGetSource&gt;</span>true<span class="code-tag">&lt;/autoGetSource&gt;</span>
    <span class="code-tag">&lt;executable&gt;</span>git<span class="code-tag">&lt;/executable&gt;</span>
    <span class="code-tag">&lt;tagOnSuccess&gt;</span>false<span class="code-tag">&lt;/tagOnSuccess&gt;</span>
    <span class="code-tag">&lt;commitBuildModifications&gt;</span>false<span class="code-tag">&lt;/commitBuildModifications&gt;</span>
    <span class="code-tag">&lt;commitUntrackedFiles&gt;</span>false<span class="code-tag">&lt;/commitUntrackedFiles&gt;</span>
    <span class="code-tag">&lt;tagCommitMessage&gt;</span>CCNet Build {0}<span class="code-tag">&lt;/tagCommitMessage&gt;</span>
    <span class="code-tag">&lt;tagNameFormat&gt;</span>CCNet-Build-{0}<span class="code-tag">&lt;/tagNameFormat&gt;</span>
    <span class="code-tag">&lt;committerName&gt;</span>Max Mustermann<span class="code-tag">&lt;/committerName&gt;</span>
    <span class="code-tag">&lt;committerEMail&gt;</span>max.mustermann@gmx.de<span class="code-tag">&lt;/committerEMail&gt;</span>
    <span class="code-tag">&lt;workingDirectory&gt;</span>c:\build\rails<span class="code-tag">&lt;/workingDirectory&gt;</span>
    <span class="code-tag">&lt;timeout&gt;</span>60000<span class="code-tag">&lt;/timeout&gt;</span>
<span class="code-tag">&lt;/sourcecontrol&gt;</span></pre>
</div></div>

<h3><a name="GitSourceControlBlock-ConfigurationElements%3A"></a>Configuration Elements:</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Node </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Required </th>
</tr>
<tr>
<td class='confluenceTd'> executable </td>
<td class='confluenceTd'> The location of the Git executable. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> git </td>
</tr>
<tr>
<td class='confluenceTd'> repository </td>
<td class='confluenceTd'> The url to your remote repository. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> N/A </td>
</tr>
<tr>
<td class='confluenceTd'> branch </td>
<td class='confluenceTd'> Remote repository branch to monitor and checkout. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> master </td>
</tr>
<tr>
<td class='confluenceTd'> autoGetSource </td>
<td class='confluenceTd'> Whether to fetch the updates from the repository and checkout the branch for a particular build. </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> true </td>
</tr>
<tr>
<td class='confluenceTd'> workingDirectory </td>
<td class='confluenceTd'> The directory containing the local git repository. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> The project working directory </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> tagOnSuccess </td>
<td class='confluenceTd'> Indicates that the repository should be tagged if the build succeeds. </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> commitBuildModifications </td>
<td class='confluenceTd'> Indicates that all modifications during the build process should be committed before tagging. This requires 'tagOnSuccess ' to be set to 'true'. </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> commitUntrackedFiles</td>
<td class='confluenceTd'> Indicates that files created during the build process should be committed before tagging. This requires 'commitBuildModifications' and 'tagOnSuccess ' to be set to 'true'. </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> tagCommitMessage </td>
<td class='confluenceTd'> Format string for the commit message of each tag. {0} is the placeholder for the current build label. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> CCNet Build {0} </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> tagNameFormat </td>
<td class='confluenceTd'> Format string for the name of each tag. Make sure you're only using allowed characters. {0} is the placeholder for the current build label. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> CCNet-Build-{0} </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> committerName </td>
<td class='confluenceTd'> Used to set the "user.name" configuration setting in the local repository. Required for the 'tagOnSuccess ' feature. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> N/A </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> committerEMail </td>
<td class='confluenceTd'> Used to set the "user.email" configuration setting in the local repository. Required for the 'tagOnSuccess ' feature. </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> N/A </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> timeout </td>
<td class='confluenceTd'> Sets the timeout period for the source control operation. See <a href="Timeout Configuration.html" title="Timeout Configuration">Timeout Configuration</a> for details. </td>
<td class='confluenceTd'> Timeout </td>
<td class='confluenceTd'> 10 minutes </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> issueUrlBuilder </td>
<td class='confluenceTd'> Converts the comment (or parts from it) into an url pointing to the issue for this build. <br clear="all" />
See <a href="IssueUrlBuilder.html" title="IssueUrlBuilder">Issue Builder</a> for more details. </td>
<td class='confluenceTd'> Group </td>
<td class='confluenceTd'> N/A </td>
<td class='confluenceTd'> false </td>
</tr>
</tbody></table>

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://confluence.public.thoughtworks.org//images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Sep 29, 2009 20:59</font></td>
		    </tr>
	    </table>
    </body>
</html>